Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class MONBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As MONDto)
 Dim Dao As New MONDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDMON As System.Int32)
 Dim Dao As New MONDao(ketnoi)
 Dao.xoa(IDMON)
 End Sub
 Public Sub sua(ByVal Dto As MONDto)
 Dim Dao As New MONDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New MONDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New MONDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoMON As MONdto = LayBangDTo(i, Dao) 
 aList.Add(dtoMON)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaTENMON( ByVal TENMON as System.String, ByVal IDMON As System.Int32 )
 Dim dao As New MONDao(ketnoi)
 dao.suaTENMON(TENMON,IDMON)
 End Sub 
 Public Sub suaIDCAPHOC( ByVal IDCAPHOC as System.Int32, ByVal IDMON As System.Int32 )
 Dim dao As New MONDao(ketnoi)
 dao.suaIDCAPHOC(IDCAPHOC,IDMON)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDMON As System.Int32 )
 Dim dao As New MONDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDMON)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.String, ByVal IDMON As System.Int32 )
 Dim dao As New MONDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDMON)
 End Sub 
 Public Function LayBangTable( ByVal IDMON As System.Int32) As DataTable
 Dim Dao As New MONDao(IDMON,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDMON As System.Int32) As IList
 Dim Dao As New MONDao(IDMON,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoMON As MONdto = LayBangDTo(i, Dao) 
 aList.Add(dtoMON)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDMON (ByVal IDMON As System.Int32) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoIDMON(IDMON)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDMON (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoIDMON(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDMON (ByVal IDMON As System.Int32) 
 Dim Dao As New MONDao(ketnoi)
 Dao.XOABangTheoIDMON(IDMON)
 End sub
 Public Function LayBangTableTheoTENMON (ByVal TENMON As System.String) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoTENMON(TENMON)
 Return Dao
 End Function
 Public Function LayBangTableTheoTENMON_like (ByVal TENMON As System.String ) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoTENMON_like (TENMON)
 Return Dao
 End Function
 Public Function LayBangTableTheoTENMON (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoTENMON(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTENMON (ByVal TENMON As System.String) 
 Dim Dao As New MONDao(ketnoi)
 Dao.XOABangTheoTENMON(TENMON)
 End sub
 Public Function LayBangTableTheoIDCAPHOC (ByVal IDCAPHOC As System.Int32) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoIDCAPHOC(IDCAPHOC)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDCAPHOC (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoIDCAPHOC(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDCAPHOC (ByVal IDCAPHOC As System.Int32) 
 Dim Dao As New MONDao(ketnoi)
 Dao.XOABangTheoIDCAPHOC(IDCAPHOC)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New MONDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.String) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU_like (ByVal GHICHU As System.String ) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoGHICHU_like (GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.String) 
 Dim Dao As New MONDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDMON As System.Int32) As MONdto
 Dim Dao As New MONDao(IDMON, ketnoi)
 Dim dto As New MONdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDMON")) = False Then
 Dto.IDMON = Dao.Rows(0)("IDMON")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("MON.IDMON")) = False Then
 Dto.IDMON = Dao.Rows(0)("MON.IDMON")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TENMON")) = False Then
 Dto.TENMON = Dao.Rows(0)("TENMON")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("MON.TENMON")) = False Then
 Dto.TENMON = Dao.Rows(0)("MON.TENMON")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDCAPHOC")) = False Then
 Dto.IDCAPHOC = Dao.Rows(0)("IDCAPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("MON.IDCAPHOC")) = False Then
 Dto.IDCAPHOC = Dao.Rows(0)("MON.IDCAPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("MON.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("MON.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("MON.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("MON.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As MONdto
 Dim dto As New MONdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDMON")) = False Then
 Dto.IDMON = Dao.Rows(i)("IDMON")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("MON.IDMON")) = False Then
 Dto.IDMON = Dao.Rows(i)("MON.IDMON")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TENMON")) = False Then
 Dto.TENMON = Dao.Rows(i)("TENMON")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("MON.TENMON")) = False Then
 Dto.TENMON = Dao.Rows(i)("MON.TENMON")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDCAPHOC")) = False Then
 Dto.IDCAPHOC = Dao.Rows(i)("IDCAPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("MON.IDCAPHOC")) = False Then
 Dto.IDCAPHOC = Dao.Rows(i)("MON.IDCAPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("MON.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("MON.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("MON.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("MON.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As MONdto
 Dim dto As New MONdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New MONDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New MONDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

